﻿using System;

namespace dbe.FoundationLibrary.Core.Extensions
{
    public static class EventHandlerExtensions
    {
        /// <summary>
        /// 触发事件
        /// </summary>
        /// <typeparam name="TEventArgs">基于EventArgs的事件类</typeparam>
        /// <param name="handler">EventHandler类的句柄</param>
        /// <param name="sender">事件关联的对象</param>
        /// <param name="e">事件参数实例</param>
        public static void RaiseEvent<TEventArgs>(this EventHandler handler, object sender, TEventArgs e) where TEventArgs : EventArgs
        {
            if (handler != null)
            {
                handler(sender, e);
            }
        }
    }
}